﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreEx.Database.Metadata;

namespace CoreEx.Database.MetaData.Implementation
{
    [Serializable]
    public class KeyInfo : IKeyInfo
    {                
        public string Name { get; set;}        
        public ITableInfo Table { get; set;}
        
        public override string ToString()
        {
            if (!string.IsNullOrEmpty(Name))
                return Name;

            return base.ToString();
        }

    }

    [Serializable]
    public class PrimaryKeyInfo : KeyInfo, IPrimaryKeyInfo
    {
        private IList<IColumnInfo> _columns = new List<IColumnInfo>();

        public IList<IColumnInfo> Columns
        {
            get { return _columns; }
        }
    }

    [Serializable]
    public class ForeignKeyInfo : KeyInfo , IForeignKeyInfo
    {
        private IList<IForeignKeyColumnInfo> _columns = new List<IForeignKeyColumnInfo>();

        public IList<IForeignKeyColumnInfo> Columns
        {
            get { return _columns; }
        }

        public ITableInfo PrimaryTable { get; set;}
    }
}
